﻿/*
 * Copyright (c) 2010 Code Owls LLC
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 
 * associated documentation files (the "Software"), to deal in the Software without restriction, 
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 
 * subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all copies or substantial 
 * portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 
 * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
*/
using System;
using System.Management.Automation;
using System.Web.Security;

namespace ASPNETMembership
{
    /// <summary>
    /// Dynamic parameters used to create a new membership provider drive.
    /// </summary>
    /// <remarks>
    /// These parameters are specifically targeted for the SqlMembershipProvider
    /// configuration.
    /// </remarks>
    /// <seealso cref="Provider.NewDriveDynamicParameters()"/>
    public class DriveParameters
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="DriveParameters"/> class.
        /// </summary>
        /// <remarks>
        /// The initial values used in this constructor match the defaults used in the web.config
        /// created for a new ASP.NET web site project.
        /// </remarks>
        public DriveParameters()
        {            
            EnablePasswordReset = true;
            EnablePasswordRetrieval = false;
            RequiresQuestionAndAnswer = false;
            RequiresUniqueEmail = false;
            MaxInvalidPasswordAttempts = 5;
            MinRequiredNonalphanumericCharacters = 0;
            MinRequiredPasswordLength = 6;
            PasswordAttemptWindow = 10;
            PasswordStrengthRegularExpression = String.Empty;
            ApplicationName = "/";
            PasswordFormat = MembershipPasswordFormat.Hashed;
        }

        /// <summary>
        /// Gets or sets the connection string.
        /// </summary>
        /// <value>The connection string.</value>
        /// <remarks>This parameter is required.</remarks>
        [Parameter( Mandatory=true )]       
        public string ConnectionString { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to enable password retrieval features of the provider.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if [enable password retrieval]; otherwise, <c>false</c>.
        /// </value>
        [Parameter]
        public bool EnablePasswordRetrieval { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to enable password reset features of the provider.
        /// </summary>
        /// <value><c>true</c> if [enable password reset]; otherwise, <c>false</c>.</value>
        [Parameter]
        public bool EnablePasswordReset { get; set; }
        
        /// <summary>
        /// Gets or sets a value indicating whether the provider requires question and answer.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if [requires question and answer]; otherwise, <c>false</c>.
        /// </value>
        [Parameter]
        public bool RequiresQuestionAndAnswer { get; set; }
        
        /// <summary>
        /// Gets or sets a value indicating whether the provider requires a unique email for each user.
        /// </summary>
        /// <value><c>true</c> if [requires unique email]; otherwise, <c>false</c>.</value>
        [Parameter]
        public bool RequiresUniqueEmail { get; set; }
        
        /// <summary>
        /// Gets or sets the password format.
        /// </summary>
        /// <value>The password format.</value>
        [Parameter]
        public MembershipPasswordFormat PasswordFormat { get; set; }
        
        /// <summary>
        /// Gets or sets the maximum number of invalid password attempts before a user object is locked.
        /// </summary>
        /// <value>The max invalid password attempts.</value>
        [Parameter]
        public int MaxInvalidPasswordAttempts { get; set; }
        
        /// <summary>
        /// Gets or sets the minimum password length.
        /// </summary>
        /// <value>The length of the min required password.</value>
        [Parameter]
        public int MinRequiredPasswordLength { get; set; }
        
        /// <summary>
        /// Gets or sets the minimum number of nonalphanumeric characters required for a password to be considered valid.
        /// </summary>
        /// <value>The min required nonalphanumeric characters.</value>
        [Parameter]
        public int MinRequiredNonalphanumericCharacters { get; set; }
        
        /// <summary>
        /// Gets or sets the password attempt window.
        /// </summary>
        /// <value>The password attempt window.</value>
        [Parameter]
        public int PasswordAttemptWindow { get; set; }
        
        /// <summary>
        /// Gets or sets the password strength regular expression.
        /// </summary>
        /// <value>The password strength regular expression.</value>
        [Parameter]
        public string PasswordStrengthRegularExpression { get; set; }
        
        /// <summary>
        /// Gets or sets the name of the application.
        /// </summary>
        /// <value>The name of the application.</value>
        [Parameter]
        public string ApplicationName { get; set; }
    }
}
